﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace Boom.Navigation
{
    public class Animation2D:MultilFrame
    {
        private int _MilliSeconds;
        private int _Elapsed = 0;

        public Animation2D(Game Mygame, ref Texture2D Texture,int MilliSeconds, int Width, int Height)
            : base(Mygame, ref Texture, Width, Height)
        {
            _MilliSeconds = MilliSeconds;   
        }

        public override void Update(GameTime gameTime)
        {
            _Elapsed += gameTime.ElapsedGameTime.Milliseconds;
            if (_Elapsed > _MilliSeconds)
            {
                _Elapsed -= _MilliSeconds;
                ActiveFrame = (ActiveFrame + 1) % FrameList.Count;
            }

            CurrentFrame = FrameList[ActiveFrame];
            base.Update(gameTime);
        }
    }
}
